-
Notifications
You must be signed in to change notification settings - Fork 1k
Use scala-cli in Getting Started page #3072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose that we assume the latest scala install which should be 3.5.0 - in which case scala-cli
should be replaced by scala
, as described in the release notes of 3.5.0 https://scala-lang.org/blog/2024/08/22/scala-3.5.0-released.html
_overviews/getting-started/index.md
Outdated
* [The migration guide](/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3. | ||
|
||
The [Scala CLI documentation](https://scala-cli.virtuslab.org/) describes the available sub-commands and how to integrate the tool with an IDE of choice. | ||
|
||
## Create a "Hello World" project with sbt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this section should be removed, or moved to a separate page.
_overviews/getting-started/index.md
Outdated
def countFiles(): Unit = | ||
val paths = os.list(os.pwd) | ||
println(paths.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def countFiles(): Unit = | |
val paths = os.list(os.pwd) | |
println(paths.length) | |
def countFiles(): Unit = | |
val paths = os.list(os.pwd) | |
println(paths.length) |
_overviews/getting-started/index.md
Outdated
@@ -145,6 +145,144 @@ To install them manually: | |||
or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail. | |||
1. Install [sbt](https://www.scala-sbt.org/download.html) | |||
|
|||
## Using the Scala CLI | |||
|
|||
Create a file named `hello.scala` with the following code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a file named `hello.scala` with the following code: | |
In a directory of your choice, which we will call `<project-dir>`, create a file named `hello.scala` with the following code: |
_overviews/getting-started/index.md
Outdated
can be thought of as an analogue to the `void` keyword found in other languages. The `println` method will print the `"Hello, World!"` | ||
string to standard output. | ||
|
||
To run the program, execute `scala run hello.scala` command. The file will be compiled and executed, with console output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To run the program, execute `scala run hello.scala` command. The file will be compiled and executed, with console output | |
To run the program, execute `scala run hello.scala` command from a terminal, within the `<project-dir>` directory. The file will be compiled and executed, with console output |
_overviews/getting-started/index.md
Outdated
def countFiles(): Unit = | ||
val paths = os.list(os.pwd) | ||
println(paths.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def countFiles(): Unit = | |
val paths = os.list(os.pwd) | |
println(paths.length) | |
def countFiles(): Unit = | |
val paths = os.list(os.pwd) | |
println(paths.length) |
_overviews/getting-started/index.md
Outdated
The printed number should be 4: `hello.scala`, `counter.scala` and two hidden directories created automatically when a program is executed: | ||
`.bsp` containing information about project used by IDEs, and `.scala-build` containing the results of compilation. | ||
|
||
As it turns out, the `os-lib` library is a part of Scala Toolkit, a collection of libraries recommended for tasks like testing, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I'm not sure showing the alternative with the toolkit is a good idea here. We should definitely link to the toolkit's home page as a "next steps" scenario. But with what we already showed above, the user already "got started". There is no need to switch to the toolkit for no immediate reason.
_overviews/getting-started/index.md
Outdated
This program is identical to the one above, with the only difference being that other toolkit libraries will also be available to use | ||
and their downloaded versions, instead of being specified by hand, will be the newest ones included in the toolkit. | ||
|
||
### Using REPL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Using REPL | |
### Using the REPL |
_overviews/getting-started/index.md
Outdated
|
||
### Using REPL | ||
|
||
You can execute code interactively using REPL provided by the `scala` command. Execute `scala` in console without any arguments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can execute code interactively using REPL provided by the `scala` command. Execute `scala` in console without any arguments. | |
You can execute code interactively using the REPL provided by the `scala` command. Execute `scala` in the console without any arguments. |
When you run the command for the first time, two hidden directories will be created: `.bsp` and `.scala-build`. The first | ||
one contains the [Build Server Protocol](https://build-server-protocol.github.io/) information for IDEs, and the second one contains the results | ||
of compilation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is useful information for a user at this stage of their learning. Consider removing that paragraph.
``` | ||
|
||
The program will be automatically compiled (with compiled classes somewhere in the newly created `.scala-build` directory) | ||
and executed, producing a similar output: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and executed, producing a similar output: | |
and executed, producing an output similar to: |
("a similar output" in English refers to another output that was previously mentioned; there is no such thing here)
_overviews/getting-started/index.md
Outdated
Compiling project (Scala 3.4.2, JVM (20)) | ||
Compiled project (Scala 3.4.2, JVM (20)) | ||
$ scala run hello.scala | ||
Compiling project (Scala 3.5.0, JVM (20)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's also a liquid variable {{site.scala-3-version}}
which can automatically update when we have a new release. e.g. its used on this page in the dropdown "Testing your setup"
_config.yml
Outdated
@@ -17,7 +17,7 @@ keywords: | |||
|
|||
scala-version: 2.13.14 | |||
scala-212-version: 2.12.19 | |||
scala-3-version: 3.4.2 | |||
scala-3-version: 3.5.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gedochao updating this variable seems to be missing from the release procedure
Co-authored-by: Sébastien Doeraene <[email protected]>
# Conflicts: # _config.yml # api/all.md
No description provided.